﻿using System;
using System.Text;
using System.Net;
using System.Net.Mail;

namespace XinYiOffice.Common
{
    public  class xyEmail
    {
        public xyEmail() { }

        #region 发送邮件
        /// <summary>
        /// 
        /// </summary>
        /// <param name="SendTo">要发送到的邮箱账号</param>
        /// <param name="Subject">是邮件标题</param>
        /// <param name="Body">邮件正文（支持html代码)</param>
        public static  void SendMail(string SendTo, string Subject, string Body)
        {
            SmtpClient client = new SmtpClient("mail.dstchina.cn");
            client.UseDefaultCredentials = true;
            client.Credentials = new NetworkCredential("active@dstchina.cn", "");
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            MailMessage message = new MailMessage("active@dstchina.cn", SendTo, Subject, Body);
            message.BodyEncoding = Encoding.GetEncoding("gb2312");
            message.IsBodyHtml = true;
            
            try
            {
                client.Send(message);
                return;
            }
            catch
            {
                return;
            }
            finally
            {
                
            }
        }
        #endregion 
    }
}